package com.ruoyi.onlinevideo.domain;/**
 * @InterfaceName: Meeting
 * @Description:
 * @Author: YourName
 * @Date: 2023-04-18
 */

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.mp.domain.CommonEntity;
import lombok.Data;

import java.util.Date;

/**
 * @InterfaceName: Meeting
 * @Description:
 * @Author: lilirui
 * @Date: 2023-04-18
 */
@Data
public class Meeting extends CommonEntity {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String title;
    private Long userId;
    private String info;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;
    private String state;
    private String meetingCode;

    @TableField(exist = false)
    private String nickName;
    public void setStatePre() {
        this.state = "未开始";
    }

    public void setStateIng() {
        this.state = "进行中";
    }

    public void setStateEnd() {
        this.state = "已结束";
    }

    public void changeState() {
        Date date = new Date();
        if (date.getTime() > endTime.getTime()) {
            setStateIng();
            return;
        } else if (date.getTime() > startTime.getTime()) {
            setStateIng();
        } else {
            setStatePre();
        }
    }
}
